package com.erp.Exception;
import com.erp.Utils.ResponseModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.LockedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 全局异常处理器
 * @createTime 2020/5/8
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(AccessDeniedException.class)
    public ResponseModel handleAuthorizationException(AccessDeniedException e) {
        log.error(e.getMessage());
        return ResponseModel.fail("没有权限，请联系管理员授权");
    }

}
